from flask import request
from src.schema import Schema
from src.core.nodes import manage
from src.api.origin import basic_decorator
from src.core.nodes.manage import all_nodes


@basic_decorator()
def nodes_bind(user):
    """多节点绑定"""
    schema = Schema.nodes_bind(**request.get_json(force=True))
    return manage.bind(schema)


@basic_decorator()
def nodes_list(user):
    """多节点列表"""
    return all_nodes()


@basic_decorator()
def bind_info(user):
    """获取绑定信息"""
    return manage.bind_info()


@basic_decorator()
def unbind_node(user):
    """节点解绑"""
    schema = Schema.unbind_node(**request.get_json(force=True))
    return manage.unbind_node(schema)


# @basic_decorator(multi_nodes=True)
# def compile_status(user):
#     """自编译软件状态"""
#     return manage.compile_status()